// 模块：销售品设计/主产品信息

// 定义app
const OfferProd = {
    delimiters: ['${', '}'],
    data() {
        return {
            sites: [
                {id: 1, title: 'Google'},
                {id: 2, title: 'Runoob'},
                {id: 3, title: 'Taobao'}
            ],
            resList: {
                "prod_list": []
            }
        }
    },
    methods: {
        // 刷新列表
        list_refresh: function (cad_id) {
            this.list_offer_prod(cad_id);
        },
        // 列举主产品信息
        list_offer_prod: function (cad_id) {
            axios
                .get('api/v1/list-cad-offer-prod/' + cad_id)
                .then(response => (this.resList["prod_list"] = response.data.result))
                .catch(function (error) {
                    console.log(error);
                })
        },
        // 退出组
        del_offer_prod(cad_id, main_prod) {
            axios({
                method: 'post', url: 'api/v1/del-offer-prod',
                data: {
                    cad_id: cad_id,
                    offer_id: main_prod
                }
            })
                .then(response => {
                    console.log(response.data);
                    this.list_offer_prod(cad_id); // 重新列举主产品信息
                })
                .catch(function (error) {
                    console.log(error);
                    alert('【操作失败】\n' + error)
                })
        }
    },
    // components: {
    //     'site-info': {
    //         template: temp_pagination
    //     }
    // }
}


// 创建Vue应用
Vue.createApp(OfferProd).mount('#collapse-offer-prod')